<%@page import="java.util.List"%>
<%@page import="entities.Category"%>
<%@page import="helpers.PaginatorHelper"%>
<%@page import="helpers.UrlHelper"%>
<%@page import="java.util.ArrayList"%>
<%
List<Category> categories = (List<Category>) request.getAttribute("categories");
int pages = (Integer) request.getAttribute("page");
boolean nextPage = (Boolean) request.getAttribute("nextPage");
boolean prevPage = (Boolean) request.getAttribute("prevPage");
PaginatorHelper paginator = (PaginatorHelper) request.getAttribute("paginator");
%>

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<jsp:include page="/admin/layouts/header.jsp" />
		<script type="text/javascript" src="/admin/js/custom/category_list.js"></script>
					<!-- Content Area -->
                	<div id="da-content-area">
                		<jsp:include page="/admin/elements/message_box.jsp" />
                		
                		<div class="grid_4">
                        	<div class="da-panel collapsible">
                            	<div class="da-panel-header">
                                	<span class="da-panel-title">
                                        <img src="/admin/images/icons/black/16/list.png" alt="" />
                                        List Category
                                    </span>
                                    
                                </div>
                                <div class="da-panel-content">
                                	<div class="dataTables_wrapper" role="grid">
	                                    <table class="da-table">
	                                        <thead>
	                                            <tr>
	                                                <th>Id</th>
	                                                <th>Title</th>
	                                                <th>Parent</th>
	                                                <th>Status</th>
	                                                <th>Count</th>
	                                                <th></th>
	                                            </tr>
	                                        </thead>
	                                        <tbody>
	                                        	<% for (int i = 0; i < categories.size(); i++) { %>
	                                            <tr>
	                                                <td><%=categories.get(i).getId() %></td>
	                                                <td><%=categories.get(i).getName() %></td>
	                                                <td><%=categories.get(i).getParentId() %></td>
	                                                <td>
	                                                	<%
														switch (categories.get(i).getStatus()) {
															case 0: 
																%>Inactive<%
																break;
															case 1:
																%>Pending<%
																break;
															case 2:
																%>Active<%
																break;
															default:
																break;
														}
														%>
	                                                </td>
	                                                <td><%=categories.get(i).getCount() %></td>
	                                                <td class="da-icon-column">
	                                                	<a href="/admin/category/edit/<%=categories.get(i).getId()%>"><img src="/admin/images/icons/color/pencil.png" /></a>
	                                                	<a href="/admin/category/delete/<%=categories.get(i).getId()%>" class="delete"><img src="/admin/images/icons/color/cross.png" /></a>
	                                                </td>
	                                            </tr>
	                                            <% } %>
	                                        </tbody>
	                                    </table>
										<div class="dataTables_paginate paging_full_numbers">
											<% if (prevPage) { %>
												<a class="previous paginate_button" href="<%=paginator.getPrev()%>">Previous</a>
											<% } else { %>
												<span class="previous paginate_button paginate_button_disabled" id="dyntable_previous">Previous</span>
											<% } %>
											<% if (nextPage) { %>
												<a class="next paginate_button"  href="<%=paginator.getNext()%>">Next</a>
											<% } else { %>
												<span class="next paginate_button paginate_button_disabled" id="dyntable_next">Next</span>
											<% } %>
										</div>
									</div>
                                </div>
                            </div>
                        </div>
                	</div>

<jsp:include page="/admin/layouts/footer.jsp" />